//
//  AuthorListVC.m
//  诗词鉴赏
//
//  Created by Steven on 2019/7/23.
//  Copyright © 2019 Steven. All rights reserved.
//

#import "AuthorListVC.h"
#import "AuthorCell.h"
#import "AuthorDetailVC.h"


@interface AuthorListVC ()

@end

@implementation AuthorListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.tableFooterView = [UIView new];
    
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return appData.authorDatas.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    Author *model = appData.authorDatas[indexPath.row];
    AuthorCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AuthorCell" forIndexPath:indexPath];
    [cell.header sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    cell.nameLabel.text = model.name;
    cell.chaodaiLabel.text = [NSString stringWithFormat:@"【%@】", model.chaodai];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    AuthorDetailVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"AuthorDetailVC"];
    
    vc.model = appData.authorDatas[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}
@end
